/**
 * create Service server, 
 * service name:/show_peroson, 
 * service data type:learn_service_userdef::Person
 * */ 
#include <ros/ros.h>
#include "learn_service_userdef/Person.h"

class ServicePersonServer {
 public:
  ServicePersonServer(std::string service_name) {
    person_srv_server_ = nh_.advertiseService(service_name, &ServicePersonServer::ServerPersonCallback, this);
  }

  ~ServicePersonServer() {

  }
 private:
  ros::NodeHandle nh_;
  ros::ServiceServer person_srv_server_;

  bool ServerPersonCallback(learn_service_userdef::Person::Request& req,
    learn_service_userdef::Person::Response& res) {
    ROS_INFO("Request data:");
    ROS_INFO("   Person: name:%s age:%d  sex:%d", req.name.c_str(), req.age, req.sex);

    res.result = "OK";
    return true;
  }
};

int main(int argc, char** argv) {
  ros::init(argc, argv, "service_person_server");
  ServicePersonServer server_node("/show_person");
  ROS_INFO("Ready to show person information.");
  ros::spin();
  return 0;
}
